#pragma once

// Copyright (c) 2010 Manuel Peinado Gallego <manuel.peinado@gmail.com>
// Distributed under the MIT License

// Common.h
//


#include "Real.h"

namespace gx
{
    enum 
    {
        X, Y, Z
    };

    const double PI = 3.14159265358979323846264338327;

    inline Real zero_if_tiny(Real x, Real tolerance=Real(1e-8)) 
    {
        return x > -tolerance && x < tolerance ? 0 : x;
    }

    struct EyeType
    {
        struct Inner
        {
            template<class T>
            operator T() const;
        }; 
    };
    typedef EyeType::Inner Eye;
    extern Eye eye;
    
    template<class T>
    Eye::operator T() const
    {   
        return T(eye);
    }

    struct ZeroType
    {
        struct Inner
        {
            template<class T>
            operator T() const;
        }; 
    };
    typedef ZeroType::Inner Zero;
    extern Zero zero;
    
    template<class T>
    Zero::operator T() const
    {   
        return T(zero);
    }
}

